package signGrammar;

import java.awt.Graphics;
import java.awt.Point;

/**
 * Implementation of IShape. Represents summary
 * of two shapes.  
 * */
public class CAddShapesExpression implements IShape {

	private final IShape a,b;
	public CAddShapesExpression(IShape a, IShape b) {
		this.a = a;
		this.b = b.cloneForHead( a.getTail() );
	}

	@Override
	public CAddShapesExpression print(Graphics graphics) {
		a.print(graphics);
		b.print(graphics);
		return this;
	}

	@Override
	public Point getHead() {
		return a.getHead();
	}

	@Override
	public Point getTail() {
		return b.getTail();
	}

	@Override
	public IShape cloneForHead(Point startPoint) {
		return new CAddShapesExpression(a.cloneForHead(startPoint),b);
	}

	@Override
	public IShape cloneForTail(Point endPoint) {
		return new CAddShapesExpression( a.cloneForTail( b.cloneForTail(endPoint).getHead() ), b);
	}
}
